# 包含公共配置
include(${CMAKE_SOURCE_DIR}/cmake/common.cmake)

# -------------------------------- 源文件收集 --------------------------------
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# 使用 CONFIGURE_DEPENDS 自动跟踪新文件
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
        "${PROJECT_ROOT_DIR}/src/*.cpp"
        "${PROJECT_ROOT_DIR}/src/*.h"
        "${PROJECT_ROOT_DIR}/src/*.ui"
        "${PROJECT_ROOT_DIR}/src/*.qrc"
)

# 在 IDE 中按目录结构组织文件
source_group(TREE ${PROJECT_ROOT_DIR} FILES ${SRC_FILES})

# -------------------------------- 可执行目标 --------------------------------
add_executable(${PROJECT_NAME} ${SRC_FILES})

# 链接库和编译器选项
target_link_libraries(${PROJECT_NAME} PRIVATE
        Qt6::Core
        Qt6::Gui
        Qt6::Widgets
        Qt6::Sql
        Qt6::Network
        project_warnings
)

# 包含目录配置
target_include_directories(${PROJECT_NAME} PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/src
        ${CMAKE_CURRENT_BINARY_DIR}
)

# -------------------------------- 构建信息注入 --------------------------------
target_compile_definitions(${PROJECT_NAME} PRIVATE
        BUILD_GIT_HASH="${GIT_HASH}"
        BUILD_GIT_BRANCH="${GIT_BRANCH}"
        BUILD_TIMESTAMP="${BUILD_TIMESTAMP}"
        PROJECT_FULL_VERSION="${PROJECT_FULL_VERSION}"
        SERVER_BUILD
)

# -------------------------------- 安装规则 --------------------------------
install_target(${PROJECT_NAME})

# -------------------------------- 创建项目结构 --------------------------------
create_project_structure() 